import java.util.Scanner;


public class PartialPlus {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String[] array = scanner.nextLine().split(" ");

    int result = getPartialNumber(array[0], array[1]) + getPartialNumber(array[2], array[3]);

    System.out.print(result);
  }

  private static int getPartialNumber(String number, String digit) {
    StringBuilder builder = new StringBuilder();
    for (int i = 0; i < number.length(); i++) {
      if (digit.charAt(0) == number.charAt(i))
        builder.append(digit);
    }

    if (builder.length() == 0)
      return 0;
    else
      return Integer.parseInt(builder.toString());
  }

}
